
package org.luxor.commons.log.event;

import org.luxor.commons.log.component.SysLogInfo;
import org.luxor.commons.log.store.SysLogStore;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

/**
 * 异步监听日志事件
 *
 * @author lengleng
 */
public class SysLogListener {

    private final SysLogStore sysLogStore;

    public SysLogListener(SysLogStore sysLogStore) {
        this.sysLogStore = sysLogStore;
    }

    @Async
    @Order
    @EventListener(SysLogEvent.class)
    public void saveSysLog(SysLogEvent event) {
        SysLogInfo sysLog = (SysLogInfo) event.getSource();
        sysLogStore.saveSysLog(sysLog);
    }

}
